﻿@model CMSMVC4.Areas.Admin.Models.NewsModels
@using CMSMVC4.MultiResource
@{
    ViewBag.Title = @Admin.News;
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

<div class="row-fluid">
    <div class="span7" style="width: 100%">
        <div class="box paint color_3">
            <div class="title">
                <h4><span>@Admin.News</span> </h4>
            </div>
            @using (Html.BeginForm("AddNews", "News", FormMethod.Post, new { area = "Admin", s = ViewBag.I, @class = "form-horizontal cmxform", autocomplete = "off" }))
            {
                @Html.HiddenFor(x => x.Pageid)
                @Html.HiddenFor(x => x.Pagelagvi)
                @Html.HiddenFor(x => x.Pagelagen)
                //////Anh Bia:
@*@Html.TextBoxFor(x => x.img, new { @class = "span12" })*@ @*<input type="button" id="btnSelectImg" value="Chon anh" />*@
                <div class="content">
                    <div class="controls span7">
                        <input class="btn" value="@Admin.SelectCoverArt" id="btnSelectImg" type="button" style="float: left" />
                        <input class="span12 valid" id="img" name="img" type="text" style="width: 65%; float: left; margin-left: 30px;" value="@Model.Img">
                    </div>
                    <br />
                    <br />
                    <br />
                    <br />
                    <div class="accordion" id="accordion4">
                        <div class="accordion-group">
                            <div class="accordion-heading"><a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion4" href="#collapseOne2">@Admin.TitleNews </a></div>
                            <div id="collapseOne2" class="accordion-body collapse in">
                                <div class="accordion-inner">
                                    <ul id="tabExample1" class="nav nav-tabs">
                                        <li class="active"><a href="#home" data-toggle="tab">@Admin.Vietnamese</a></li>
                                        <li><a href="#profile" data-toggle="tab">@Admin.English</a></li>
                                    </ul>
                                    <div class="tab-content">
                                        <div class="tab-pane fade in active" id="home">
                                            <label class="control-label span3">@Admin.TitleNews <span class="help-block">@Admin.TitleOfNews</span> </label>
                                            <div class="controls span7">
                                                <input name="TitleVi" type="text" class="span12" value="@Model.TitleVi" />
                                                @Html.ValidationMessageFor(x => x.TitleVi)
                                            </div>
                                        </div>
                                        <div class="tab-pane fade" id="profile">
                                            <label class="control-label span3">@Admin.TitleNews <span class="help-block">@Admin.TitleOfNews</span> </label>
                                            <div class="controls span7">
                                                <input name="TitleEn" type="text" class="span12" value="@Model.TitleEn" />
                                                @Html.ValidationMessageFor(x => x.TitleEn)
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="accordion-group">
                            <div class="accordion-heading"><a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion4" href="#collapseTwo2">@Admin.Content</a></div>
                            <div id="collapseTwo2" class="accordion-body collapse" style="height: 0px;">
                                <div class="accordion-inner">
                                    <ul id="tabExample2" class="nav nav-tabs">
                                        <li class="active"><a href="#home1" data-toggle="tab">@Admin.Vietnamese</a></li>
                                        <li><a href="#profile1" data-toggle="tab">@Admin.English</a></li>
                                    </ul>
                                    <div class="tab-content">
                                        <div class="tab-pane fade in active" id="home1">
                                            <textarea cols="80" id="aol" rows="10" name="ContentVi">@Model.ContentVi</textarea>
                                        </div>
                                        <div class="tab-pane fade" id="profile1">
                                            <textarea cols="80" id="aol1" rows="10" name="ContentEn">@Model.ContentEn</textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="accordion-group">
                            <div class="accordion-heading"><a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion4" href="#collapseThree2">@Admin.Summary </a></div>
                            <div id="collapseThree2" class="accordion-body collapse" style="height: 0px;">
                                <div class="accordion-inner">
                                    <ul id="tabExample3" class="nav nav-tabs">
                                        <li class="active"><a href="#home2" data-toggle="tab">@Admin.Vietnamese</a></li>
                                        <li><a href="#profile2" data-toggle="tab">@Admin.English</a></li>
                                    </ul>
                                    <div class="tab-content">
                                        <div class="tab-pane fade in active" id="home2">
                                            <textarea cols="80" id="aol4" rows="10" name="SumVi">@Model.SumVi</textarea>
                                        </div>
                                        <div class="tab-pane fade" id="profile2">
                                            <textarea cols="80" id="aol3" rows="10" name="SumEn">@Model.SumEn</textarea>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-row control-group row-fluid">
                        <label class="control-label span3">@Admin.NewsCategories</label>
                        <div class="controls span7">
                            <div style="width: 50%; float: left">
                                @Html.DropDownListFor(x => x.CateId, Model.Listdata, new { @class = "chzn-select", id = "default-select" })
                            </div>
                            @*<select data-placeholder="Choose your favorite character..." class="chzn-select" id="default-select">
                                <option value=""></option>
                                <option value="Bender">Bender</option>
                                <option value="Zapp Brannigan">Zapp Brannigan</option>
                                <option value="Zoidberg">Zoidberg</option>
                                <option selected="selected" value="Kif Kroker">Kif Kroker</option>
                            </select>*@
                            @{
                if (ViewBag.Active != 0)
                {
                                <a href="@Url.Action("Active","News")" class="btn" style="float: left; margin-left: 20px" >Disable</a>
                }
                else
                {
                                <a href="@Url.Action("Active","News")" class="btn" style="float: left; margin-left: 20px" >Enable</a>
                }
                            }
                            @if (ViewBag.Active == 1)
                            {
                                <div class="btn-group inline" style="margin-left: 20px">
                                    <button class="btn btn-success dropdown-toggle" data-toggle="dropdown">@Admin.Actions<span class="caret"></span></button>
                                    <ul class="dropdown-menu">
                                        <li>
                                            <a rel="tooltip" data-ajax="true"
                                                data-ajax-method="Get" data-ajax-mode="replace" data-ajax-success="showEditContact()"
                                                data-ajax-update="#dialog" href="/Admin/News/NewCategory">@Admin.AddNews</a>

                                        </li>
                                        <li>
                                            <a rel="tooltip" onclick="del()">@Admin.DeleteCategoryNews</a>
                                            <script type="text/javascript">
                                                function del() {
                                                    var vl = $('#default-select').val();
                                                    var rt = confirm("are you sure?");
                                                    if (rt) {
                                                        window.location = "/Admin/News/DeleteCate/" + vl;
                                                    }
                                                }
                                            </script>
                                        </li>
                                    </ul>
                                </div>
                            }
                        </div>
                    </div>
                    <div class="form-actions row-fluid">
                        <div class="span7 offset3">
                            <button type="submit" class="btn btn-primary">@Admin.SaveChange</button>
                            <a href="@Url.Action("ListNews","News")"><button type="button" class="btn btn-secondary">@Admin.Cancel</button></a>
                        </div>
                    </div>
                </div>
            }
        </div>
        <!-- End .box -->
    </div>
</div>
<div id="boxes">
    <div id="dialog" style="overflow: auto"></div>
    <div id="dialog_nen"></div>
</div>

<script type="text/javascript">
    var editor;
    function createEditor(languageCode) {
        if (editor) editor.destroy();
        editor = CKEDITOR.replace('aol1', {
            language: languageCode
        });
        editor = CKEDITOR.replace('aol', {
            language: languageCode
        });
        editor = CKEDITOR.replace('aol3', {
            language: languageCode
        });
        editor = CKEDITOR.replace('aol4', {
            language: languageCode
        });

    }

    $(function () {
        createEditor('@ViewBag.l');
        $("#btnSelectImg").click(function () {
            var finder = new CKFinder();
            finder.selectActionFunction = function (fileUrl) {
                $('#img').val(fileUrl);
            };
            finder.popup();
        });

    });
</script>
